package com.lxd.sunso.product.controller;

import java.util.Arrays;
import java.util.Map;

import com.lxd.sunso.common.utils.PageUtils;
import com.lxd.sunso.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lxd.sunso.product.entity.DatatypeEntity;
import com.lxd.sunso.product.service.DatatypeService;




/**
 * 
 *
 * @author lxd
 * @email sunlightcs@gmail.com
 * @date 2020-12-30 18:06:30
 */
@RestController
@RequestMapping("product/datatype")
public class DatatypeController {
    @Autowired
    private DatatypeService datatypeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("product:datatype:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = datatypeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("product:datatype:info")
    public R info(@PathVariable("id") Long id){
        DatatypeEntity datatype = datatypeService.getById(id);

        return R.ok().put("datatype", datatype);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("product:datatype:save")
    public R save(@RequestBody DatatypeEntity datatype){
        datatypeService.save(datatype);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("product:datatype:update")
    public R update(@RequestBody DatatypeEntity datatype){
        datatypeService.updateById(datatype);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("product:datatype:delete")
    public R delete(@RequestBody Long[] ids){
        datatypeService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }
}
